<?php

/* @var $this yii\web\View */
use common\models\Attribute;
use common\models\Category;
use frontend\widgets\GoodsFilter;
use yii\helpers\ArrayHelper;

/* @var $sort yii\data\Sort */

$category = (new \yii\db\Query())->select('id as value, cate_name as label')->from('category')->all();

$this->title = '找场地';
?>
<div id="g-p1">

    <div class="container">

        <div class="filter">
            <dl class="clearfix">
                <dt>选择城市：</dt>
                <dd>
                    <?= GoodsFilter::widget([
                        'attribute' => 'city',
                        'filterItems' => [
                            '上海', '北京', '广州'
                        ]
                    ])?>
                </dd>
            </dl>
            <dl class="clearfix">
                <dt>会议类型：</dt>
                <dd>
                    <?= GoodsFilter::widget([
                        'attribute' => 'cate',
                        'filterItems' => $category
                    ])?>
                </dd>
            </dl>
            <dl class="clearfix">
                <dt>容纳人数：</dt>
                <dd>
                    <?= GoodsFilter::widget([
                        'attribute' => 'accom',
                        'filterItems' => ['10-30', '30-50', '50-80', '80-100', '100-150', '150-200', '200+']
                    ])?>
                </dd>
            </dl>
            <dl class="clearfix">
                <dt>场地布局：</dt>
                <dd>
                    <?= GoodsFilter::widget([
                        'attribute' => 'layout',
                        'filterItems' => Attribute::findOne(['id' => 5])->value
                    ])?>
                </dd>
            </dl>
        </div>

        <div class="row">

            <?= \yii\widgets\ListView::widget([
                'dataProvider' => $dataProvider,
                'itemView' => '_items',
                'layout' => "{summary}\n{items}\n{pager}",
                'pager' => [
                    'options' => [
                        'class' => 'pagination pull-right'
                    ],
                    'prevPageLabel' => '上一页',
                    'nextPageLabel' => '下一页',
                ],
                'summary' => "<h4>
                                <span><b>{count}</b> 个场地符合要求</span>
                                <u>
                                    {$sort->link('order', ['label' => '推荐顺序'])}
                                    {$sort->link('acreage', ['label' => '场地面积'])}
                                    {$sort->link('price', ['label' => '场地价格'])}
                                    {$sort->link('comment', ['label' => '评论数'])}
                                </u>
                                <em>
                                    <b><small>{page} / </small>{pageCount}</b>
                                </em>
                            </h4>"
            ])?>

        </div>
    </div>
</div>